<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
 <style type="text/css">
.STYLE6 {
color:#FFFFFF;
font-size:13px;
}
.STYLE7 {
color:#336699;
font-family:"Arial","宋体";
font-size:12px;
line-height:130%;
}
body {
	background-image: url(images/bg2.gif);
	background-repeat: repeat;
}
</style>
<script src="js/jquery.js"></script>
	<script type="text/javascript">
	var bo=[false,false,false];
	function changeButton(index,bool){
		bo[index]=bool;
		if(bool){
			for(var i=0;i<bo.length;i++){
				if(!bo[i]){
					return;
				}
			}
			document.getElementById("sub").disabled=false;
		}else{
			document.getElementById("sub").disabled=true;
		}
	}
	function checkOldpwd(){
		var pwd1 = $("#pwd1").val();
		var pwd = $("#userPassword").val();
		if(pwd1==pwd) {
			$("#font1").attr("color","green");
			$("#font1").html("<img src=\"images/check_right.gif\"/>&nbsp;原始密码正确");
			changeButton(0,true);
		}else {
		    $("#font1").attr("color","red");
			$("#font1").html("<img src=\"images/check_error.gif\"/>&nbsp;您输入的原始密码错误请重新输入");
			changeButton(0,false);
		}
	}
	function checkPwd(){
		checkPwdIsSame();
		var pwd = $("#pwd2").val();
	   if(pwd.length>=6&&pwd.length<=16) {
			$("#font2").attr("color","green");
			$("#font2").html("<img src=\"images/check_right.gif\"/>&nbsp;密码符合6-16位的要求");
			changeButton(1,true);
		}else {
			$("#font2").attr("color","red");
			$("#font2").html("<img src=\"images/check_error.gif\"/>&nbsp;密码不符合6-12位要求");
			changeButton(1,false);
		}
	}
	function checkPwdIsSame(){
		
		var pwd1 = $("#pwd2").val();
		var pwd2 = $("#pwd3").val();
		if(pwd1==pwd2&&pwd1.length!="") {
			$("#font3").attr("color","green");
			$("#font3").html("<img src=\"images/check_right.gif\"/>&nbsp;两次密码相同");
			changeButton(2,true);
		}else {
			$("#font3").attr("color","red");
			$("#font3").html("<img src=\"images/check_error.gif\"/>&nbsp;您输入的两次密码不同");
			changeButton(2,false);
		}
	}

	function send(){	
		$.post("changePassword",{'user.password':$("#pwd2").val()},function(data){
			if(data=="true"){
				window.parent.show_Message("修改密码成功!","green");
				window.parent.tb_remove();
			}else{
				window.parent.show_Message("修改密码失败!,请稍后再试!","red");
				window.parent.tb_remove();
			}
		},"text")
	}
	</script>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
  
  <body>
   

<table width="100%" border="1" align="center">
<tr >
		<td width="40%" bgcolor="#1e84b4" class="STYLE6"><div>请输入旧密码：</div></td>
		<td width="27%"><input class="STYLE7" type="password" name="pwd1" id="pwd1" onKeyUp="checkOldpwd()" /></td>
		<td width="33%"><font id="font1" size="2" color="#808080">请输入原始密码</font></td>
	</tr>
	<tr>
		<td bgcolor="#1e84b4" class="STYLE6"><div>请输入您的新密码：</div></td>
		<td><input class="STYLE7" type="password" name="user.password" value="" id="pwd2" onKeyUp="checkPwd()" /></td>
		<td><font id="font2" size="2" color="#808080">请输入6-16位密码</font></td>
	</tr>
	<tr>
		<td bgcolor="#1e84b4" class="STYLE6"><div>请再次输入您的新密码：</div></td>
		<td><input class="STYLE7" type="password" name="pwd3" value="" id="pwd3" onKeyUp="checkPwdIsSame()" /></td>
		<td><font id="font3" size="2" color="#808080">&nbsp;</font></td>
	</tr>
	<tr>
		<td colspan="2" align="center"><input type="button" id="sub" value="确定" disabled="disabled" onClick="send()"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="reset" id="reset" value="重填" /></td>
		<td><font id="font4">&nbsp;</font></td>
	</tr>
	<tr>
		<td><input type="hidden" id="userPassword" name="user.password" value="${user.password}"></td>
	</tr>
</table>

</body>
</html>
